/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

function jQueryAjaxErrorHandler(handlers) {
    return function (event, jq, textStatus, errorThrown) {
        switch (jq.status) {
            case 401:
                if (handlers == null || handlers['401'] == null) {
                    layer.alert('身份验证失败！<br>可能为网页超时，请重新登录后再试！', {icon: 0, title: '系统提示'});
                } else {
                    handlers['401']();
                }
                break;
            case 403:
                if (handlers == null || handlers['403'] == null) {
                    layer.alert('您无权使用该功能！', {icon: 0, title: '系统提示'});
                } else {
                    handlers['403']();
                }
                break;
            case 404:
                if (handlers == null || handlers['404'] == null) {
                    layer.alert('找不到您所请求的功能！', {icon: 0, title: '系统提示'});
                } else {
                    handlers['404']();
                }
                break;
            case 408:
                if (handlers == null || handlers['408'] == null) {
                    layer.alert('您还未登录，或网页超时，请重新登录！', {icon: 0, title: '系统提示'});
                } else {
                    handlers['408']();
                }
                break;
            case 500:
                if (handlers == null || handlers['500'] == null) {
                    layer.alert('服务暂不可用，请稍后重试！', {icon: 0, title: '系统提示'});
                } else {
                    handlers['500']();
                }
                break;
            default:
                layer.alert('服务暂不可用，请稍后重试！', {icon: 0, title: '系统提示'});
        }
    };
}
